<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="se" uri="/WEB-INF/serviceTypeTag.tld"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="java.util.List"%>
<%@page import="com.doone.telmarket.domain.ServiceProduct"%>
<%@page import="com.doone.telmarket.domain.ServicePage"%>
<%@page import="com.doone.telmarket.domain.ServicePageContent"%>
<%@page import="java.util.HashMap"%>
<%@page import="java.util.Map"%>
	<%
		if(session.getAttribute("isAdminLogined")==null){
			return;
		}else{
			String isAddminLogined = session.getAttribute("isAdminLogined").toString();
			if(!("true".equals(isAddminLogined))){
				response.sendRedirect("login.jsp");
				return;
			}
		}
		
	%>
<%

if(session.getAttribute("servicePage")!=null){
	session.removeAttribute("servicePage");
	session.removeAttribute("descMap");
	session.removeAttribute("fileMap");
}
%>


<%@page import="java.util.Enumeration"%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>main</title>

<link rel="stylesheet" rev="stylesheet"
	href="${pageContext.request.contextPath}/css/admin/style-admin.css"
	type="text/css" media="all" />
<script type="text/javascript"
	src="${pageContext.request.contextPath}/ckeditor/ckeditor.js"></script>

<script src="${pageContext.request.contextPath}/js/jquery.js"
	type="text/javascript"></script>
<script
	src="${pageContext.request.contextPath}/js/jquery.ui.draggable.js"
	type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/jquery.alerts.js"
	type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ajaxfileupload.js"
	type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/common.js"
	type="text/javascript"></script>
<link href="${pageContext.request.contextPath}/css/jquery.alerts.css"
	rel="stylesheet" type="text/css" media="screen" />

<script type="text/javascript">
window.onload = function(){
	CKEDITOR.id = "serviceContent";
	//CKEDITOR.replace('serviceContent');
	
	var contextPath = $("#contextPath").val();

	CKEDITOR.replace('serviceContent',{
		filebrowserImageUploadUrl:contextPath+'/admin/upload-image',
		filebrowserFlashUploadUrl:contextPath+'/admin/upload-flash'
		});
	
	 
	$("#fom").submit( function(){
		if($("#serviceName").val()==""){
			jAlert('请输入增值业务名称', '消息');
			$("#serviceName").focus();
			return false;
		}

		if($('#orderMode').val()!="ITF" ){
			if($("#redirectUrl").val()==""){
				jAlert('请输入增值业务跳转或认证的URL', '消息');
				$("#redirectUrl").focus();
				return false;
			}
		}
		
		if($("#serviceType").val()=="0"){
			jAlert('请选择增值业务服务类别', '消息');
			$("#serviceType").focus();
			return false;
		}
		if($("#serviceClassify").val()=="0"){
			jAlert('请选择增值业务功能类别', '消息');
			$("#serviceClassify").focus();
			return false;
		}
		
		
		if($("#spname").val()==""){
			jAlert('请输入增值业务提供商', '消息');
			$("#spname").focus();
			return false;
		}
		if($("#serviceSummaryContent").val()==""){
			jAlert('请输入增值业务的简要描述', '消息');
			$("#serviceSummaryContent").focus();
			return false;
		}
		if(document.getElementById("serviceDescTable").rows.length==1){
			jAlert('请输入增值业务的描述信息', '消息');
			return false;
		}
		var tb = document.getElementById("serviceDescTable").childNodes;
	   	var tr = tb[0].childNodes;
	   	var length = tr.length;
	   	//alert("增值业务描述信息"+length+"条");
	   	if(length<2){
	   		jAlert("增值业务描述信息至少要保留一条","消息");
	   		return;
	   	}
		return true;

		
	});


	var oderMode = document.getElementById("orderMode");
	oderMode.onchange = function(){
		var value = oderMode.options[oderMode.options.selectedIndex].value;
		if(value!="CRM"||value!="ISMP"){
			document.getElementById("redirectUrlTd").style.display = "";
		}else{
			document.getElementById("redirectUrlTd").style.display = "none";
		}
	}
}

</script>


<style type="text/css">
<!--
.atten {
	font-size: 12px;
	font-weight: normal;
	color: #F00;
}
-->
</style>
</head>

<body class="ContentBody">
<div style="z-index: 1;height: 1000">

<div class="MainDiv"><input  type="hidden"  id="contextPath" value="${pageContext.request.contextPath}">
<table width="99%" border="0" cellpadding="0" cellspacing="0"
	class="CContent">
	<tr>
		<th class="tablestyle_title">增值业务管理</th>
	</tr>
	<tr>
		<td class="CPanel">
		<table border="0" cellpadding="0" cellspacing="0" style="width: 100%">
			<tr>
				<td align="left"><a
					href="${pageContext.request.contextPath}/admin/service/service.jsp">新增增值业务</a>
					 <a href="${pageContext.request.contextPath}/admin/service/toOperationService.jsp">编辑增值业务</a>

				</td>
			</tr>

			<tr align="center">
				<td class="TablePanel"></td>
			</tr>
			<tr>
				<TD width="100%">
				

				
				<div >
				<fieldset style="height: 100%;"><legend>增加增值业务(带*的为必填)</legend>
		<form action="${pageContext.request.contextPath}/admin/saveService?saveType=save" method="post" name="fom"
	       id="fom" enctype="multipart/form-data">
				<table border="0" cellpadding="2" cellspacing="1"
					style="width: 100%" id="firstTable">

					<!-- 	<tr>
						<td nowrap align="right" width="13%">增值业务代码：</td>
						<td width="32%">&nbsp;<input type="text" maxlength="30" 
							name="serviceId" id="serviceId" /><span style="color:black">*　 请输入数字类型的增值业务代码</span></td>
					</tr>
					 -->
					<tr>
						<td nowrap align="right" width="13%">增值业务名称:</td>
						<td width="32%">&nbsp;<input type="text" maxlength="30"
							name="serviceName" id="serviceName"><span
							style="color: black">*</span></td>
					</tr>
					<tr>
						<td nowrap align="right" width="13%">增值服务类别:</td>
						<td width="32%">&nbsp;<se:showServiceType /></td>
					</tr>
					<tr>
						<td nowrap align="right" width="13%">增值功能类别:</td>
						<td width="32%">&nbsp;<se:showServiceClassify /></td>
					</tr>
					<tr>
						<td nowrap align="right" width="13%">订购方式:</td>
						<td width="32%">&nbsp;<select name="orderMode" id="orderMode">
								<option value="ISM">ISMP平台</option>
								<option value="CRM">CRM平台</option>
								
								<option value="RDT">直接跳转</option>
							<!--  	<option value="SSO">单点认证</option>-->
							</select>
						</td>
					</tr>
					
					<tr>
						<td nowrap align="right" width="13%">增值编码类别:</td>
						<td width="32%">&nbsp;<select name="serviceCodeType">
							<option value="P">产品类型</option>
							<option value="C">套餐类型</option>
						</select></td>
					</tr>
					<tr id="redirectUrlTd" style="display: none;">
						<td nowrap align="right" width="13%">跳转或单点认证URL:</td>
						<td width="32%">&nbsp;<input value="http://" type="text" maxlength="30"
							name="redirectUrl" id="redirectUrl"><span
							style="color: black">*</span></td>
					</tr>
					<tr>
						<td nowrap align="right" width="13%">增值业务服务提供商:</td>
						<td width="32%">&nbsp;<input type="text" name="spName"
							id="spname"><span style="color: black">*</span></td>
					</tr>
					<tr>
						<td nowrap align="right" width="13%">增值业务简要描述:</td>
						<td width="32%">&nbsp;<input type="text" name="serviceSummaryContent"
							id="serviceSummaryContent" size="60"><span style="color: black">*</span></td>
					</tr>
					<tr>
						<td nowrap align="right" width="13%">增值业务推荐星级:</td>
						<td width="32%">&nbsp;<select name="serviceCodeGrade"
							id="grade">
							<option value="1">&nbsp;1&nbsp;</option>
							<option value="2">&nbsp;2&nbsp;</option>
							<option value="3">&nbsp;3&nbsp;</option>
							<option value="4">&nbsp;4&nbsp;</option>
							<option value="5">&nbsp;5&nbsp;</option>
						</select>星</td>
					</tr>
					<tr>
						<td nowrap align="right" width="13%">上传增值业务缩略图:</td>
						<td nowrap  width="13%" id="smallTd"><input class="button" id="smallbutton" type="button" value="增值业务缩略图" onclick="uploadSmall();">请选择JPG,GIF,PNG格式的图片上传.宽度(大于80px,小于100px).高度(大于55px,小于75px)
						</td>
					</tr>
					<tr>
						<td nowrap align="right" width="13%">上传增值业务LOGO图:</td>
						<td nowrap  width="13%" id="logoTd">
						<input class="button" type="button" value="增值业务LOGO图" id="logobutton" onclick="uploadLogo();"  class="button" />请选择JPG,GIF,PNG格式的图片上传.宽度(大于170px,小于250px).高度(大于167px,小于200px)
						</td>
					</tr>
					<tr>
						<td nowrap align="right" width="13%">上传增值业务FLASH:</td>
						<td nowrap  width="13%" id="flashTd">
						<input class="button" type="button" value="增值业务FLASH" id="flashbutton" onclick="uploadFlash();"  class="button">请选择小于10M的SWF格式的FLASH文件上传</td>
					</tr>
					<tr>
						<td nowrap align="right" width="13%">增值业务介绍信息:</td>
						<td width="32%"><input type="button"
							value="增加增值业务介绍信息" onclick="showEditor();"  class="button" /><span style="color:black">*　 例：开通方式，使用方法等</span></td>
					</tr>
					<tr>
							<TD colspan="2" align="center" height="50px"><input type="submit"
								value="保存" class="button" /> <input type="button" name="Submit2"
								value="返回" class="button" onclick="window.history.go(-1);" />
								</TD>
						</tr>
				</table>
				</form>
				<br />
				</fieldset>
				</div>
				<div >
					<fieldset style="height: 100%;"><legend>已增加增值业务介绍信息</legend>
						<table width="730" border="1px" id="serviceDescTable">
							  <tr>
							    <td width="123">标题</td>
							    <td width="591">内容</td>
							    <td width="50">操作</td>
							  </tr>
							  <%
							  	if(session.getAttribute("descMap")!=null){
							  		
							  		Map map = (HashMap)session.getAttribute("descMap");
								  		for(Object obj : map.keySet()) {     
										    Object key = obj;     
										    Object value = map.get(obj);
										    
										
							  		%> 
							  <tr>
							    <td width="100"><%=key.toString() %></td>
							    <td width="150"><%=value.toString() %></td>
							    <td width="50"><input type='button' onclick="delServiceDesc('<%=key.toString() %>',this);" value=删除 class='button' /></td>
							   </tr>
							  		<%
								  		}  
							  	}
							   
							  %>
							  
					</table>
					<br><br><br><br><br><br><br><br><br><br><br><br><br>
					</fieldset>
				
				</div>
				</TD>
			</TR>
		</TABLE>
		</td>
	</tr>
	
	
</TABLE>
</div>

</div>

<div id="bgLayer" style="float:left;position:absolute;background:#CCCCCC;left:0px;top:0px;width:100%;height:1000;filter:alpha(style=0,opacity=50);display:none;z-index:2;"></div>
<div id="Layer1"  style=" display:none; border:0;background-image: url(/images/3Gsjj.jpg);position:absolute;top:1px; left:1px; width:528px; height:426px; z-index:3; text-align:left" >

  <div style="width: 760px;border-color: red;border: 1px solid;background-color: white;">
  <fieldset>
  	<legend>增加增值业务详细信息</legend>
  	<table>
  	<tr>
  		<td>
  		　标题:　<input type="text" id="descTitle" maxlength="6">
  		</td>
  		
  		
  		
  	</tr>
  		<tr>
			<td width="32%">&nbsp;&nbsp;内容：<br/>
				<textarea rows="3" cols="5" name="serviceContent" id="serviceContent"></textarea>
			</td>
		</tr>
		<TR>
		<TD colspan="2" align="center" height="50px"><input type="button"
			value="保存" style="cursor: hand" onclick="submitText('${pageContext.request.contextPath}/admin/saveServiceDesc')" class="button" /> <input type="button" name="Submit2"
			value="返回" style="cursor: hand" class="button" onclick="displaySmallImage('Layer1');" />
			</TD>
	</TR>
  	</table>
  </fieldset>
  	
  </div>

</div>


<div id="Layer2"  style=" display:none; border:0;background-image: url(/images/3Gsjj.jpg);position:absolute;top:1px; left:1px; width:528px; height:70px; z-index:3; text-align:left" >

  <div style="width: 450px;border-color: red;border: 1px solid;background-color: white;height: 130px">
  <fieldset>
  	<legend>上传增值业务缩略图</legend>
  	<table>
  	<tr>
  		<td>
  		　请选择：<input type="file" name="uploadFile" id="smallImage1">
  		<input type="button"  class="button" id="smallImageUpload" value="上传">
  		<input type="button" onclick="displaySmallImage('Layer2');" class="button"  value="取消"　>
  		</td>
  		<td>
  		</td>
  	</tr>
  	</table>
  </fieldset>
  	
  </div>

</div>

<div id="Layer3"  style=" display:none; border:0;background-image: url(/images/3Gsjj.jpg);position:absolute;top:1px; left:1px; width:528px; height:70px; z-index:3; text-align:left" >

  <div style="width: 450px;border-color: red;border: 1px solid;background-color: white;height: 130px">
  <fieldset>
  	<legend>上传增值业务LOGO图</legend>
  	<table>
  	<tr>
  		<td>
  		　请选择：<input type="file" name="uploadFile" id="logoImage1"><input type="button"  class="button"  id="logoImageUpload" value="上传">
  		<input type="button" onclick="displaySmallImage('Layer3');" class="button" value="取消">
  		</td>
  		<td>
  		</td>
  	</tr>
  	</table>
  </fieldset>
  	
  </div>

</div>

<div id="Layer4"  style=" display:none; border:0;background-image: url(/images/3Gsjj.jpg);position:absolute;top:1px; left:1px; width:528px; height:70px; z-index:3; text-align:left" >

  <div style="width: 450px;border-color: red;border: 1px solid;background-color: white;height: 130px">
  <fieldset>
  	<legend>上传增值业务FLASH</legend>
  	<table>
  	<tr>
  		<td>
  		　请选择：<input type="file" name="uploadFile" id="flash1">
  		<input type="button" id="flashUpload"  class="button"  value="上传">
  		<input type="button" onclick="displaySmallImage('Layer4');" class="button" value="取消">
  		</td>
  		<td>
  		</td>
  	</tr>
  	</table>
  </fieldset>
  </div>
</div>

<form action="cancelOprationService" method="post" id="cancelForm"></form>
</body>
</html>